package com.yunji.web.order;

import com.yunji.common.base.BaseController;
import com.yunji.common.base.response.Response;
import com.yunji.common.base.response.ResponseHelper;
import com.yunji.common.utils.ExcelUtil;
import com.yunji.order.business.TradeBusiness;
import com.yunji.order.dto.OrderScaleParam;
import com.yunji.order.dto.TradeParam;
import com.yunji.order.vo.OrderScaleVO;
import com.yunji.order.vo.TradeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.web.order
 * @Title: TradeController
 * @Description: 交易后台信息
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-04-16 13:43:26      V1.0        HuaAo       新建类
 */
@Api(tags = "管理端-交易模块")
@RestController
@RequestMapping("/container/trade/")
public class TradeController extends BaseController {
    @Resource
    private TradeBusiness business;

    @ApiOperation("钱包流水/交易明细列表")
    @PostMapping("/tradeList")
    public Response<List<TradeVO>> tradeList(@RequestBody TradeParam params) {
        List<TradeVO> list = business.tradeList(params);
        return ResponseHelper.successWithPage(list, params.getTotal());
    }

    @ApiOperation("钱包流水导出/交易明细列表导出")
    @PostMapping("/tradeExport")
    public void tradeExport(@RequestBody TradeParam trade) {
        trade.setExport(true);
        List<TradeVO> list = business.tradeList(trade);
        ExcelUtil<TradeVO> util = new ExcelUtil<>(TradeVO.class);
        util.exportExcel(response, list, "交易明细");
    }

    @ApiOperation("佣金明细")
    @PostMapping("/scaleList")
    public Response<List<OrderScaleVO>> scaleList(@RequestBody OrderScaleParam param) {
        return ResponseHelper.successWithPage(business.scaleList(param));
    }

    @ApiOperation("佣金明细导出")
    @PostMapping("/scaleExport")
    public void scaleExport(@RequestBody OrderScaleParam param) {
        List<OrderScaleVO> list = business.scaleList(param);
        ExcelUtil<OrderScaleVO> util = new ExcelUtil<>(OrderScaleVO.class);
        util.exportExcel(response, list, "钱包流水导出");
    }
}
